import {BASE_URL,TIMEOUT} from "@/service/request/config";
import axios from "axios";
class YHRequest{
    instance
    constructor(baseURL,timeout) {
        this.instance=axios.create({
            baseURL,
            timeout
        })
        // this.instance.interceptors.response.use(res=>res.data,err=>err)
    }
    request(config){
        return new Promise((resolve,reject)=>{
            this.instance.request(config).then((res)=>{
                // console.log(res)
                resolve(res.data)
            }).catch(err=>{
                reject(err)
            })
        })
    }
    get(config){
        return this.request({...config,method:"get"})
    }
    post(config){
        // console.log(config)
        return this.request({...config,method:"post"})
    }
}
const yhRequest=new YHRequest(BASE_URL,TIMEOUT)
export default yhRequest